import React, { Component } from 'react'

export default class Count extends Component {
  constructor() {
    super()
    //state是固定的
    this.state = {
      // 对象里面的属性,随便写
      c: 0,
      msg: 'hello state',
    }
  }
  render() {
    return (
      <div>
        <p>{this.state.c}</p>
        <p>{this.state.msg}</p>
        <button
          onClick={() => {
            // 注意: setState是异步的
            this.setState({
              c: this.state.c + 1, //c:1
            })

            // console.log(this.state.c)
          }}
        >
          +
        </button>
      </div>
    )
  }
}
